package com.maggroup.conference_system.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.maggroup.conference_system.entity.Meeting;
import com.maggroup.conference_system.service.MeetingService;


@RestController
@RequestMapping("/meeting")
public class MeetingController {
	
	@Autowired
	private MeetingService meetingService;

	@RequestMapping(value = "/", method = RequestMethod.GET)
	public List<Meeting> list() {
		List<Meeting> meetingList = meetingService.getMeetingList();
		return meetingList;
	}

	@RequestMapping(value = "/", method = RequestMethod.POST)
	public Meeting create(@RequestBody Meeting meeting) {
		Meeting newMeeting = meetingService.addMeeting(meeting);
		return newMeeting;
	}
	
	@RequestMapping(value = "/{id}", method = RequestMethod.GET)
	public Meeting searchOne(@PathVariable(name = "id") Integer id) {
		return meetingService.getOne(id);
	}
	
}
